package org.eclipse.moquette.parser.netty;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import org.eclipse.moquette.proto.messages.AbstractMessage;
import org.eclipse.moquette.proto.messages.PingReqMessage;

/**
 * PingReq 编码
 * 心跳频率在CONNECT可变头部“Keep Alive timer”中定义时间，单位为秒，无符号16位short表示。
 * Created by alex on 15-5-25.
 */
public class PingReqEncoder extends DemuxEncoder<PingReqMessage> {


    @Override
    protected void encode(ChannelHandlerContext ctx, PingReqMessage msg, ByteBuf out) {
        //就一个固定头部搞定
        out.writeByte(AbstractMessage.PINGREQ << 4).writeByte(0);
    }
}
